package net.pinnoocle.playshoppc.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.pinnoocle.playcommon.response.BaseResult;
import net.pinnoocle.playdao.entity.shopPc.shop.SaveShopSettingParams;
import net.pinnoocle.playdao.entity.shopPc.shop.ShopChangePassParams;
import net.pinnoocle.playdao.entity.shopPc.shop.ShopDetailVo;
import net.pinnoocle.playservice.service.impl.ShopServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ye
 * @Description
 * @create 2021-11-25 13:47
 */
@RestController
@RequestMapping("/shop")
@Api(tags = "店铺相关")

public class ShopController {

    @Autowired
    ShopServiceImpl shopService;

    @GetMapping("shopDetail")
    @ApiOperation("店铺信息")
    public BaseResult<ShopDetailVo> shopDetail(){
        return new BaseResult<ShopDetailVo>().ok(shopService.shopDetail());
    }

    @PostMapping("saveShopInfo")
    @ApiOperation("店铺设置")
    public BaseResult<String> saveShopInfo(@RequestBody SaveShopSettingParams params){
        boolean result = shopService.saveShopInfo(params);
        if(result){
            return new BaseResult<String>().success("店铺设置成功");
        }
        return new BaseResult<String>().error("店铺设置失败");
    }

    @PostMapping("changePass")
    @ApiOperation("店铺修改登录密码")
    public BaseResult<String> changePass(@RequestBody ShopChangePassParams params){
        boolean result = shopService.changePass(params);
        if(result){
            return new BaseResult<String>().success("登录密码修改成功");
        }
        return new BaseResult<String>().error("登录密码修改失败");
    }
}
